const path = require('path')
const resolve = dir => {
  return path.join(__dirname, dir)
}

const publicPath = process.env.NODE_ENV === 'production' ? '/' : '/'

// node vue-cli-service serve --target lib
const args = process.argv.slice(2)
const hasTarget = args.indexOf('--target') >= 0

module.exports = {
  // 打印表格副标题时需要(实验阶段)
  runtimeCompiler: true,
  productionSourceMap: false,
  pages: {
    index: {
      entry: hasTarget ? 'src/index.js' : 'example/main.js',
      template: 'public/index.html',
      filename: 'index.html'
    }
  },
  publicPath: publicPath,
  lintOnSave: false,
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('_c', resolve('src/components'))
  },
  // build打包时，--watch时默认为css内联样式，此处设置成非内联模式(样式生成到单独的css文件中)；非 --watch 默认就是true
  css: {
    extract: true
  }
}
